package com.itmk.web.sys_role_menu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmk.web.sys_role_menu.entity.RoleMenu;
import com.itmk.web.sys_role_menu.entity.SaveMenuParm;
import com.itmk.web.sys_role_menu.mapper.RoleMenuMapper;
import com.itmk.web.sys_role_menu.service.RoleMenuSrevice;
import org.springframework.stereotype.Service;

@Service
public class RoleMenuSreviceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuSrevice {


    @Override
    public void saveRoleMenu(SaveMenuParm parm) {
        //实现保存角色权限表，先把所有的都删除，然后再保存
        LambdaQueryWrapper<RoleMenu> queryWrapper = new LambdaQueryWrapper<RoleMenu>();
        queryWrapper.eq(RoleMenu::getRoleId, parm.getRoleId());
        this.baseMapper.delete(queryWrapper);
        //保存
        this.baseMapper.saveRoleMenu(parm.getRoleId(),parm.getMenuIdList());
    }
}

